<template>
  <div class="patient_main">
    <div class="main" style="padding-bottom: 0;">
      <div class="content">
        <br/>
        <el-text style="font-size: 20px;color: #333333;margin-left: 20px;">常见科室</el-text>
        <el-row :gutter="3" class="row-style" justify="start">
          <div class="department_content" v-for="(item, key) in department.department_list" @click="toDoctor(item.id, item.name)">
            <el-col :span="8" class="col-style" v-if="item.direction == 0">
              <div class="rightCard" >
                <img :src="item.cover" style="width: 40px;height: 40px;margin-top: 30px"/>
                <br/>
                <el-text>{{ item.name }}</el-text>
              </div>
            </el-col>
          </div>
        </el-row>
        <el-text style="font-size: 20px;color: #333333;margin-left: 20px;">内科</el-text>
        <el-row :gutter="3" class="row-style" justify="start">
          <div class="department_content" v-for="(item, key) in department.department_list" @click="toDoctor(item.id, item.name)">
            <el-col :span="8" class="col-style" v-if="item.direction == 1">
              <div class="rightCard" >
                <img :src="item.cover" style="width: 40px;height: 40px;margin-top: 30px"/>
                <br/>
                <el-text>{{ item.name }}</el-text>
              </div>
            </el-col>
          </div>
        </el-row>
        <el-text style="font-size: 20px;color: #333333;margin-left: 20px;">外科</el-text>
        <el-row :gutter="3" class="row-style" justify="start">
          <div class="department_content" v-for="(item, key) in department.department_list" @click="toDoctor(item.id, item.name)">
            <el-col :span="8" class="col-style" v-if="item.direction == 2">
              <div class="rightCard" >
                <img :src="item.cover" style="width: 40px;height: 40px;margin-top: 30px"/>
                <br/>
                <el-text>{{ item.name }}</el-text>
              </div>
            </el-col>
          </div>
        </el-row>
        <el-text style="font-size: 20px;color: #333333;margin-left: 20px;">其他</el-text>
        <el-row :gutter="3" class="row-style" justify="start">
          <div class="department_content" v-for="(item, key) in department.department_list" @click="toDoctor(item.id, item.name)">
            <el-col :span="8" class="col-style" v-if="item.direction == 3">
              <div class="rightCard" >
                <img :src="item.cover" style="width: 40px;height: 40px;margin-top: 30px"/>
                <br/>
                <el-text>{{ item.name }}</el-text>
              </div>
            </el-col>
          </div>
        </el-row>
      </div>
    </div>
  </div>
</template>

<script setup>
import {ref, watch, onMounted} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import department from "../../api/Department.js";
import { useRouter, useRoute} from "vue-router";
const router = useRouter()
const route = useRoute()


onMounted(()=>{
  department.get_department_list_all()
})

const toDoctor=(id, name)=>{
  router.push(`/doctorList?id=${id}&name=${name}`)
}


</script>

<style scoped>
.patient_main {
  background-color: #f4f4f4;
  height: auto;
}

.main {
  width: 768px;
  height: 100%;
  margin: 0 auto;
}
.content {
  background-color: white;
  width: 100%;
  height: 100%;
}
.rightCard{
  width: 225px;
  height: 123px;
  background-color: #fafafa;
}
.row-style {
  padding: 30px;
}

.col-style {
  margin-right: 5px;
  padding-bottom: 10px;
  text-align: center;
}
.department_content{
  margin: 0;
}
</style>